package spring_learn.a03;

import javafx.beans.binding.ObjectExpression;

import java.util.ArrayList;
import java.util.List;


//设计模式之 模版方法
public class MethodTemplate {

    public static void main(String[] args) {
        myBeanFactory myBeanFactory=new myBeanFactory();
        myBeanFactory.addProcessor(o -> {
            System.out.println("解析auto注解");
        });
        myBeanFactory.addProcessor(o -> {
            System.out.println("解析resource注解");
        });
        myBeanFactory.getBean();
    }

    static class myBeanFactory{
        private List<myBeanPostProcessor> processorList=new ArrayList<>();

        public void addProcessor(myBeanPostProcessor processor){
            processorList.add(processor);
        }

        public Object getBean(){
            Object o=new Object();
            System.out.println("构造");
            System.out.println("依赖注入");
            for (myBeanPostProcessor processor:processorList)
                processor.inject(o);
            System.out.println("初始化");
            return o;
        }
    }

    static interface myBeanPostProcessor{
        public void inject(Object o);
    }
}
